# Tutorial: http://aquaregia.gitbooks.io/tmux-productive-mouse-free-development_zh/content/book-content/Chapter2.html
#
# 0. Mode-Keys
setw -g mode-keys vi

# 1. unbind-key Ctrl+b
unbind C-b

# 2. set prefix Ctrl+a
# -g : global
set -g prefix C-a

# 3. Change the Default Delay
set -g escape-time 1

# 4. Setting the Window and Panes Index
#   Set the first Window Index as 1
set -g base-index 1
#
setw -g pane-base-index 1

# 5. Creating a Shortcut to Reload the Configuration
#   Prefix r (that is Ctrl+a+r)
#   \; to split commands
bind r source-file ~/.tmux.conf\; display "Reloaded!"
## -n to tell tmux use CTRL+r
# bind-key -n C-r source-file ./.tmux.conf

# 6. Sending the Prefix to other applications
bind C-a send-prefix

# 7. split panes
bind | split-window -h
bind - split-window -v

# 8. Remapping Movement Keys
bind h select-pane -L
bind l select-pane -R
bind j select-pane -D
bind k select-pane -U
# +- Panes
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+

# 9. Resizing Panes
# bind H resize-pane -L 5
# bind J resize-pane -D 5
# bind k resize-pane -U 5
# bind L resize-pane -R 5
# -r repeated  即只要按一次prefix即可
# 5 是 延迟500ms
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# 10. Handling the Mouse
#
setw -g mode-mouse off
# 开启模式
# setw -g mode-mouse on
# 选择pane
# set -g mouse-select-pane on
# 更改pane大小
# set -g mouse-resize-pane on
# 选择窗口
# set -g mouse-select-window on

# 11. Configuring Colors
set -g default-terminal "screen-256color"

# *. tmux plugin
# https://github.com/tmux-plugins/tpm
# resurrect : save or restore session
#       Keys: prefix + C-s/C-r
set -g @tpm_plugins '              \
  tmux-plugins/tpm                 \
  tmux-plugins/tmux-sensible       \
  tmux-plugins/tmux-resurrect      \
'

# Initializes Tmux plugin manager
# Keep this line at the very bottom of tmux.conf
run-shell '~/.tmux/plugins/tpm/tpm'
